package com.hs.mobile.service;

import java.util.List;

import com.hs.mobile.model.Category;
import com.hs.mobile.dao.category.CategoryDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("categoryService")
public class CategoryServiceImpl implements CategoryService {
	
	@Autowired	
	CategoryDAO categoryDAO;
	/**
	 * @name setterCategoryDAO
	 * @param categoryDAO
	 */
	public void setCategoryDAO( CategoryDAO categoryDAO )
	{
		this.categoryDAO = categoryDAO;
	}
	/**
	 * 
	 * @return categoryDAO
	 */
	public CategoryDAO getCategoryDAO()
	{
		return categoryDAO;
	}
	@Override
	public void save(Category category) {
		// TODO Auto-generated method stub
		System.out.println("__ save category __ ");		
		categoryDAO.add(category);		
	}
	@Override
	public void update(Category category) {
		// TODO Auto-generated method stub
		System.out.println("__ update category __");
		categoryDAO.update(category);
	}
	@Override
	public void delete(long id) {
		// TODO Auto-generated method stub
		System.out.println("__ delete category __");
		Category delCategory = (Category) categoryDAO.getById(id);
		System.out.println("name: " + delCategory.getName());
		categoryDAO.delete(delCategory);
	}
	@Override
	public Category findCategoryById(long id) {
		// TODO Auto-generated method stub
		System.out.println("__ find Category __ ");
		Category category = categoryDAO.findByCategoryId(id);
		return category;
	}
	@Override
	public List<Category> getAllCategories() {
		// TODO Auto-generated method stub
		System.out.println("__ get totally Categories __ ");
		List<Category> listCategory = categoryDAO.getListAll();
		return listCategory;
	}
}
